Skip to content

fix(visual-track): stop offsetting fitted media by the Clip border twice - #424

Open
rudycelekli wants to merge 1 commit into
hypit-ai:mainfrom
rudycelekli:fix/visual-track-border-offset
Open

rudycelekli wants to merge 1 commit into
hypit-ai:mainfrom
rudycelekli:fix/visual-track-border-offset

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 18, 2026 •

Copy link
Copy Markdown

A Visual Clip with a border-width draws its picture border px to the right of and below the place Spatial resolved for it. It then crops the picture's right and bottom border px:

400x400 Clip, border-width 20, fit stretch; lowered elements rendered in headless Chrome
Spatial content box:  { x: 120, y: 120, w: 360, h: 360 }
picture on screen:    { x: 140, y: 140, w: 360, h: 360 }   <- 20px gap top-left, 20px clipped bottom-right

visualContentFrame already insets the fit frame by the border (and padding), so the sample mapping is in picture coordinates inside the border. lowerVisualClipElements made that mapping local by subtracting the frame's border-box origin. The layers are absolutely positioned children of the :frame element, which carries the CSS border, and CSS positions such children from the parent's padding edge. The border was therefore added a second time, and the frame's overflow: hidden cut off the overflow. DepthStack Cards are lowered through the same function.

The sample layers' local origin is now the frame's padding edge (frame + border). This applies to the mapping translation, the sampling transform-origin and the blur clip-path polygon. The frame element's own clip-path (pathData) still resolves against the border box and is unchanged. Clips without a border lower exactly as before.

The existing frame-treatment test (2px border) encoded the shift. Its expected values change from matrix(…,62,12) / 200px 150px to matrix(…,60,10) / 198px 148px; the old values fail with the change. With the change, the Chrome render above places the picture at 120,120.

Checks run:

  • node --import tsx --test packages/visual-track/test/*.test.ts packages/depth-stack/test/*.test.ts (33 passed)
  • node --import tsx --test packages/html-program/test/*.test.ts packages/film/test/*.test.ts packages/composition/test/*.test.ts (50 passed)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant